import { Route, Redirect } from "react-router-dom"
import { isAuth } from "@/utils";

export const AuthRoute = ({ component: Component, ...rest }) => {
  return <Route {...rest} render={((props) => {
    // state 是路由跳转额外携带的参数
    return isAuth() ? <Component /> : <Redirect to={{ pathname: '/login', state: { from: props.location.pathname } }} ></Redirect>
  })}></Route>
}
